
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/plotting.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:46 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Plotting &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../_static/sympy-notailtext-favicon.ico"/>
    <link href="plotting.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Polynomial Manipulation" href="polys/index.html" />
    <link rel="prev" title="Solving Beam Bending Problems using Singularity Functions" href="physics/continuum_mechanics/beam_problems.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="polys/index.html" title="Polynomial Manipulation"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="physics/continuum_mechanics/beam_problems.html" title="Solving Beam Bending Problems using Singularity Functions"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Plotting</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.plotting.plot">
<span id="plotting"></span><h1>Plotting<a class="headerlink" href="#module-sympy.plotting.plot" title="Permalink to this headline">¶</a></h1>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>The plotting module allows you to make 2-dimensional and 3-dimensional plots.
Presently the plots are rendered using <code class="docutils literal notranslate"><span class="pre">matplotlib</span></code> as a backend. It is
also possible to plot 2-dimensional plots using a <code class="docutils literal notranslate"><span class="pre">TextBackend</span></code> if you don’t
have <code class="docutils literal notranslate"><span class="pre">matplotlib</span></code>.</p>
<p>The plotting module has the following functions:</p>
<ul class="simple">
<li><p>plot: Plots 2D line plots.</p></li>
<li><p>plot_parametric: Plots 2D parametric plots.</p></li>
<li><p>plot_implicit: Plots 2D implicit and region plots.</p></li>
<li><p>plot3d: Plots 3D plots of functions in two variables.</p></li>
<li><p>plot3d_parametric_line: Plots 3D line plots, defined by a parameter.</p></li>
<li><p>plot3d_parametric_surface: Plots 3D parametric surface plots.</p></li>
</ul>
<p>The above functions are only for convenience and ease of use. It is possible to
plot any plot by passing the corresponding <code class="docutils literal notranslate"><span class="pre">Series</span></code> class to <code class="docutils literal notranslate"><span class="pre">Plot</span></code> as
argument.</p>
</section>
<section id="plot-class">
<h2>Plot Class<a class="headerlink" href="#plot-class" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.Plot">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">Plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">title</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xlabel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ylabel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">zlabel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aspect_ratio</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'auto'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xlim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ylim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis_center</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'auto'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axis</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xscale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'linear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">yscale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'linear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">autoscale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">margin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">annotations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">markers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rectangles</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fill</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">backend</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L59-L329"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Plot" title="Permalink to this definition">¶</a></dt>
<dd><p>The central class of the plotting module.</p>
<p class="rubric">Explanation</p>
<p>For interactive work the function <code class="docutils literal notranslate"><span class="pre">plot</span></code> is better suited.</p>
<p>This class permits the plotting of sympy expressions using numerous
backends (matplotlib, textplot, the old pyglet module for sympy, Google
charts api, etc).</p>
<p>The figure can contain an arbitrary number of plots of sympy expressions,
lists of coordinates of points, etc. Plot has a private attribute _series that
contains all data series to be plotted (expressions for lines or surfaces,
lists of points, etc (all subclasses of BaseSeries)). Those data series are
instances of classes not imported by <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">sympy</span> <span class="pre">import</span> <span class="pre">*</span></code>.</p>
<p>The customization of the figure is on two levels. Global options that
concern the figure as a whole (eg title, xlabel, scale, etc) and
per-data series options (eg name) and aesthetics (eg. color, point shape,
line type, etc.).</p>
<p>The difference between options and aesthetics is that an aesthetic can be
a function of the coordinates (or parameters in a parametric plot). The
supported values for an aesthetic are:
- None (the backend uses default values)
- a constant
- a function of one variable (the first coordinate or parameter)
- a function of two variables (the first and second coordinate or
parameters)
- a function of three variables (only in nonparametric 3D plots)
Their implementation depends on the backend so they may not work in some
backends.</p>
<p>If the plot is parametric and the arity of the aesthetic function permits
it the aesthetic is calculated over parameters and not over coordinates.
If the arity does not permit calculation over parameters the calculation is
done over coordinates.</p>
<p>Only cartesian coordinates are supported for the moment, but you can use
the parametric plots to plot in polar, spherical and cylindrical
coordinates.</p>
<p>The arguments for the constructor Plot must be subclasses of BaseSeries.</p>
<p>Any global option can be specified as a keyword argument.</p>
<p>The global options for a figure are:</p>
<ul class="simple">
<li><p>title : str</p></li>
<li><p>xlabel : str</p></li>
<li><p>ylabel : str</p></li>
<li><p>zlabel : str</p></li>
<li><p>legend : bool</p></li>
<li><p>xscale : {‘linear’, ‘log’}</p></li>
<li><p>yscale : {‘linear’, ‘log’}</p></li>
<li><p>axis : bool</p></li>
<li><p>axis_center : tuple of two floats or {‘center’, ‘auto’}</p></li>
<li><p>xlim : tuple of two floats</p></li>
<li><p>ylim : tuple of two floats</p></li>
<li><p>aspect_ratio : tuple of two floats or {‘auto’}</p></li>
<li><p>autoscale : bool</p></li>
<li><p>margin : float in [0, 1]</p></li>
<li><p>backend : {‘default’, ‘matplotlib’, ‘text’} or a subclass of BaseBackend</p></li>
<li><p>size : optional tuple of two floats, (width, height); default: None</p></li>
</ul>
<p>The per data series options and aesthetics are:
There are none in the base series. See below for options for subclasses.</p>
<p>Some data series support additional aesthetics or options:</p>
<p>ListSeries, LineOver1DRangeSeries, Parametric2DLineSeries,
Parametric3DLineSeries support the following:</p>
<p>Aesthetics:</p>
<ul>
<li><dl>
<dt>line_color<span class="classifier">string, or float, or function, optional</span></dt><dd><p>Specifies the color for the plot, which depends on the backend being
used.</p>
<p>For example, if <code class="docutils literal notranslate"><span class="pre">MatplotlibBackend</span></code> is being used, then
Matplotlib string colors are acceptable (“red”, “r”, “cyan”, “c”, …).
Alternatively, we can use a float number <span class="math notranslate nohighlight">\(0 &lt; color &lt; 1\)</span> wrapped in a
string (for example, <span class="math notranslate nohighlight">\(line_color=&quot;0.5&quot;\)</span>) to specify grayscale colors.
Alternatively, We can specify a function returning a single
float value: this will be used to apply a color-loop (for example,
<span class="math notranslate nohighlight">\(line_color=lambda x: math.cos(x)\)</span>).</p>
<p>Note that by setting line_color, it would be applied simultaneously
to all the series.</p>
</dd>
</dl>
</li>
</ul>
<p>options:</p>
<ul class="simple">
<li><p>label : str</p></li>
<li><p>steps : bool</p></li>
<li><p>integers_only : bool</p></li>
</ul>
<p>SurfaceOver2DRangeSeries, ParametricSurfaceSeries support the following:</p>
<p>aesthetics:</p>
<ul class="simple">
<li><p>surface_color : function which returns a float.</p></li>
</ul>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.Plot.append">
<span class="sig-name descname"><span class="pre">append</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L260-L295"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Plot.append" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds an element from a plot’s series to an existing plot.</p>
<p class="rubric">Examples</p>
<p>Consider two <code class="docutils literal notranslate"><span class="pre">Plot</span></code> objects, <code class="docutils literal notranslate"><span class="pre">p1</span></code> and <code class="docutils literal notranslate"><span class="pre">p2</span></code>. To add the
second plot’s first series object to the first, use the
<code class="docutils literal notranslate"><span class="pre">append</span></code> method, like so:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span> <span class="o">=</span> <span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">show</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p2</span> <span class="o">=</span> <span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">show</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p2</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-10.0, 10.0)</span>
<span class="go">[1]: cartesian line: x for x over (-10.0, 10.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-1.png">png</a>, <a class="reference external" href="plotting-1.hires.png">hires.png</a>, <a class="reference external" href="plotting-1.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-1.png" class="plot-directive" src="../_images/plotting-1.png" />
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.Plot.extend" title="sympy.plotting.plot.Plot.extend"><code class="xref py py-obj docutils literal notranslate"><span class="pre">extend</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.Plot.extend">
<span class="sig-name descname"><span class="pre">extend</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">arg</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L297-L329"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Plot.extend" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds all series from another plot.</p>
<p class="rubric">Examples</p>
<p>Consider two <code class="docutils literal notranslate"><span class="pre">Plot</span></code> objects, <code class="docutils literal notranslate"><span class="pre">p1</span></code> and <code class="docutils literal notranslate"><span class="pre">p2</span></code>. To add the
second plot to the first, use the <code class="docutils literal notranslate"><span class="pre">extend</span></code> method, like so:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span> <span class="o">=</span> <span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">show</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p2</span> <span class="o">=</span> <span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="n">x</span><span class="p">,</span> <span class="n">show</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">p2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-10.0, 10.0)</span>
<span class="go">[1]: cartesian line: x for x over (-10.0, 10.0)</span>
<span class="go">[2]: cartesian line: -x for x over (-10.0, 10.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-2.png">png</a>, <a class="reference external" href="plotting-2.hires.png">hires.png</a>, <a class="reference external" href="plotting-2.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-2.png" class="plot-directive" src="../_images/plotting-2.png" />
</figure>
</dd></dl>

</dd></dl>

</section>
<section id="plotting-function-reference">
<h2>Plotting Function Reference<a class="headerlink" href="#plotting-function-reference" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.plot.plot">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1639-L1845"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.plot" title="Permalink to this definition">¶</a></dt>
<dd><p>Plots a function of a single variable as a curve.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>args :</strong></p>
<blockquote>
<div><p>The first argument is the expression representing the function
of single variable to be plotted.</p>
<p>The last argument is a 3-tuple denoting the range of the free
variable. e.g. <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">0,</span> <span class="pre">5)</span></code></p>
<p>Typical usage examples are in the followings:</p>
<ul class="simple">
<li><dl class="simple">
<dt>Plotting a single expression with a single range.</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot(expr,</span> <span class="pre">range,</span> <span class="pre">**kwargs)</span></code></p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>Plotting a single expression with the default range (-10, 10).</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot(expr,</span> <span class="pre">**kwargs)</span></code></p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>Plotting multiple expressions with a single range.</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot(expr1,</span> <span class="pre">expr2,</span> <span class="pre">...,</span> <span class="pre">range,</span> <span class="pre">**kwargs)</span></code></p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>Plotting multiple expressions with multiple ranges.</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot((expr1,</span> <span class="pre">range1),</span> <span class="pre">(expr2,</span> <span class="pre">range2),</span> <span class="pre">...,</span> <span class="pre">**kwargs)</span></code></p>
</dd>
</dl>
</li>
</ul>
<p>It is best practice to specify range explicitly because default
range may change in the future if a more advanced default range
detection algorithm is implemented.</p>
</div></blockquote>
<p><strong>show</strong> : bool, optional</p>
<blockquote>
<div><p>The default value is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>. Set show to <code class="docutils literal notranslate"><span class="pre">False</span></code> and
the function will not display the plot. The returned instance of
the <code class="docutils literal notranslate"><span class="pre">Plot</span></code> class can then be used to save or display the plot
by calling the <code class="docutils literal notranslate"><span class="pre">save()</span></code> and <code class="docutils literal notranslate"><span class="pre">show()</span></code> methods respectively.</p>
</div></blockquote>
<p><strong>line_color</strong> : string, or float, or function, optional</p>
<blockquote>
<div><p>Specifies the color for the plot.
See <code class="docutils literal notranslate"><span class="pre">Plot</span></code> to see how to set color for the plots.
Note that by setting <code class="docutils literal notranslate"><span class="pre">line_color</span></code>, it would be applied simultaneously
to all the series.</p>
</div></blockquote>
<p><strong>title</strong> : str, optional</p>
<blockquote>
<div><p>Title of the plot. It is set to the latex representation of
the expression, if the plot has only one expression.</p>
</div></blockquote>
<p><strong>label</strong> : str, optional</p>
<blockquote>
<div><p>The label of the expression in the plot. It will be used when
called with <code class="docutils literal notranslate"><span class="pre">legend</span></code>. Default is the name of the expression.
e.g. <code class="docutils literal notranslate"><span class="pre">sin(x)</span></code></p>
</div></blockquote>
<p><strong>xlabel</strong> : str, optional</p>
<blockquote>
<div><p>Label for the x-axis.</p>
</div></blockquote>
<p><strong>ylabel</strong> : str, optional</p>
<blockquote>
<div><p>Label for the y-axis.</p>
</div></blockquote>
<p><strong>xscale</strong> : ‘linear’ or ‘log’, optional</p>
<blockquote>
<div><p>Sets the scaling of the x-axis.</p>
</div></blockquote>
<p><strong>yscale</strong> : ‘linear’ or ‘log’, optional</p>
<blockquote>
<div><p>Sets the scaling of the y-axis.</p>
</div></blockquote>
<p><strong>axis_center</strong> : (float, float), optional</p>
<blockquote>
<div><p>Tuple of two floats denoting the coordinates of the center or
{‘center’, ‘auto’}</p>
</div></blockquote>
<p><strong>xlim</strong> : (float, float), optional</p>
<blockquote>
<div><p>Denotes the x-axis limits, <code class="docutils literal notranslate"><span class="pre">(min,</span> <span class="pre">max)`</span></code>.</p>
</div></blockquote>
<p><strong>ylim</strong> : (float, float), optional</p>
<blockquote>
<div><p>Denotes the y-axis limits, <code class="docutils literal notranslate"><span class="pre">(min,</span> <span class="pre">max)`</span></code>.</p>
</div></blockquote>
<p><strong>annotations</strong> : list, optional</p>
<blockquote>
<div><p>A list of dictionaries specifying the type of annotation
required. The keys in the dictionary should be equivalent
to the arguments of the matplotlib’s annotate() function.</p>
</div></blockquote>
<p><strong>markers</strong> : list, optional</p>
<blockquote>
<div><p>A list of dictionaries specifying the type the markers required.
The keys in the dictionary should be equivalent to the arguments
of the matplotlib’s plot() function along with the marker
related keyworded arguments.</p>
</div></blockquote>
<p><strong>rectangles</strong> : list, optional</p>
<blockquote>
<div><p>A list of dictionaries specifying the dimensions of the
rectangles to be plotted. The keys in the dictionary should be
equivalent to the arguments of the matplotlib’s
patches.Rectangle class.</p>
</div></blockquote>
<p><strong>fill</strong> : dict, optional</p>
<blockquote>
<div><p>A dictionary specifying the type of color filling required in
the plot. The keys in the dictionary should be equivalent to the
arguments of the matplotlib’s fill_between() function.</p>
</div></blockquote>
<p><strong>adaptive</strong> : bool, optional</p>
<blockquote>
<div><p>The default value is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>. Set adaptive to <code class="docutils literal notranslate"><span class="pre">False</span></code>
and specify <code class="docutils literal notranslate"><span class="pre">nb_of_points</span></code> if uniform sampling is required.</p>
<p>The plotting uses an adaptive algorithm which samples
recursively to accurately plot. The adaptive algorithm uses a
random point near the midpoint of two points that has to be
further sampled. Hence the same plots can appear slightly
different.</p>
</div></blockquote>
<p><strong>depth</strong> : int, optional</p>
<blockquote>
<div><p>Recursion depth of the adaptive algorithm. A depth of value
<code class="docutils literal notranslate"><span class="pre">n</span></code> samples a maximum of <span class="math notranslate nohighlight">\(2^{n}\)</span> points.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">adaptive</span></code> flag is set to <code class="docutils literal notranslate"><span class="pre">False</span></code>, this will be
ignored.</p>
</div></blockquote>
<p><strong>nb_of_points</strong> : int, optional</p>
<blockquote>
<div><p>Used when the <code class="docutils literal notranslate"><span class="pre">adaptive</span></code> is set to <code class="docutils literal notranslate"><span class="pre">False</span></code>. The function
is uniformly sampled at <code class="docutils literal notranslate"><span class="pre">nb_of_points</span></code> number of points.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">adaptive</span></code> flag is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>, this will be
ignored.</p>
</div></blockquote>
<p><strong>size</strong> : (float, float), optional</p>
<blockquote>
<div><p>A tuple in the form (width, height) in inches to specify the size of
the overall figure. The default value is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>, meaning
the size will be set by the default backend.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Single Plot</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-4.png">png</a>, <a class="reference external" href="plotting-4.hires.png">hires.png</a>, <a class="reference external" href="plotting-4.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-4.png" class="plot-directive" src="../_images/plotting-4.png" />
</figure>
<p>Multiple plots with single range.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian line: x for x over (-5.0, 5.0)</span>
<span class="go">[1]: cartesian line: x**2 for x over (-5.0, 5.0)</span>
<span class="go">[2]: cartesian line: x**3 for x over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-5.png">png</a>, <a class="reference external" href="plotting-5.hires.png">hires.png</a>, <a class="reference external" href="plotting-5.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-5.png" class="plot-directive" src="../_images/plotting-5.png" />
</figure>
<p>Multiple plots with different ranges.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">6</span><span class="p">,</span> <span class="mi">6</span><span class="p">)),</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-6.0, 6.0)</span>
<span class="go">[1]: cartesian line: x for x over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-6.png">png</a>, <a class="reference external" href="plotting-6.hires.png">hires.png</a>, <a class="reference external" href="plotting-6.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-6.png" class="plot-directive" src="../_images/plotting-6.png" />
</figure>
<p>No adaptive sampling.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">adaptive</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nb_of_points</span><span class="o">=</span><span class="mi">400</span><span class="p">)</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-10.0, 10.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-7.png">png</a>, <a class="reference external" href="plotting-7.hires.png">hires.png</a>, <a class="reference external" href="plotting-7.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-7.png" class="plot-directive" src="../_images/plotting-7.png" />
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.Plot" title="sympy.plotting.plot.Plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Plot</span></code></a>, <a class="reference internal" href="#sympy.plotting.plot.LineOver1DRangeSeries" title="sympy.plotting.plot.LineOver1DRangeSeries"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LineOver1DRangeSeries</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.plot.plot_parametric">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">plot_parametric</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1848-L2037"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.plot_parametric" title="Permalink to this definition">¶</a></dt>
<dd><p>Plots a 2D parametric curve.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>args</strong></p>
<blockquote>
<div><p>Common specifications are:</p>
<ul class="simple">
<li><dl class="simple">
<dt>Plotting a single parametric curve with a range</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot_parametric((expr_x,</span> <span class="pre">expr_y),</span> <span class="pre">range)</span></code></p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>Plotting multiple parametric curves with the same range</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot_parametric((expr_x,</span> <span class="pre">expr_y),</span> <span class="pre">...,</span> <span class="pre">range)</span></code></p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>Plotting multiple parametric curves with different ranges</dt><dd><p><code class="docutils literal notranslate"><span class="pre">plot_parametric((expr_x,</span> <span class="pre">expr_y,</span> <span class="pre">range),</span> <span class="pre">...)</span></code></p>
</dd>
</dl>
</li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">expr_x</span></code> is the expression representing <span class="math notranslate nohighlight">\(x\)</span> component of the
parametric function.</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_y</span></code> is the expression representing <span class="math notranslate nohighlight">\(y\)</span> component of the
parametric function.</p>
<p><code class="docutils literal notranslate"><span class="pre">range</span></code> is a 3-tuple denoting the parameter symbol, start and
stop. For example, <code class="docutils literal notranslate"><span class="pre">(u,</span> <span class="pre">0,</span> <span class="pre">5)</span></code>.</p>
<p>If the range is not specified, then a default range of (-10, 10)
is used.</p>
<p>However, if the arguments are specified as
<code class="docutils literal notranslate"><span class="pre">(expr_x,</span> <span class="pre">expr_y,</span> <span class="pre">range),</span> <span class="pre">...</span></code>, you must specify the ranges
for each expressions manually.</p>
<p>Default range may change in the future if a more advanced
algorithm is implemented.</p>
</div></blockquote>
<p><strong>adaptive</strong> : bool, optional</p>
<blockquote>
<div><p>Specifies whether to use the adaptive sampling or not.</p>
<p>The default value is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>. Set adaptive to <code class="docutils literal notranslate"><span class="pre">False</span></code>
and specify <code class="docutils literal notranslate"><span class="pre">nb_of_points</span></code> if uniform sampling is required.</p>
</div></blockquote>
<p><strong>depth</strong> :  int, optional</p>
<blockquote>
<div><p>The recursion depth of the adaptive algorithm. A depth of
value <span class="math notranslate nohighlight">\(n\)</span> samples a maximum of <span class="math notranslate nohighlight">\(2^n\)</span> points.</p>
</div></blockquote>
<p><strong>nb_of_points</strong> : int, optional</p>
<blockquote>
<div><p>Used when the <code class="docutils literal notranslate"><span class="pre">adaptive</span></code> flag is set to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<p>Specifies the number of the points used for the uniform
sampling.</p>
</div></blockquote>
<p><strong>line_color</strong> : string, or float, or function, optional</p>
<blockquote>
<div><p>Specifies the color for the plot.
See <code class="docutils literal notranslate"><span class="pre">Plot</span></code> to see how to set color for the plots.
Note that by setting <code class="docutils literal notranslate"><span class="pre">line_color</span></code>, it would be applied simultaneously
to all the series.</p>
</div></blockquote>
<p><strong>label</strong> : str, optional</p>
<blockquote>
<div><p>The label of the expression in the plot. It will be used when
called with <code class="docutils literal notranslate"><span class="pre">legend</span></code>. Default is the name of the expression.
e.g. <code class="docutils literal notranslate"><span class="pre">sin(x)</span></code></p>
</div></blockquote>
<p><strong>xlabel</strong> : str, optional</p>
<blockquote>
<div><p>Label for the x-axis.</p>
</div></blockquote>
<p><strong>ylabel</strong> : str, optional</p>
<blockquote>
<div><p>Label for the y-axis.</p>
</div></blockquote>
<p><strong>xscale</strong> : ‘linear’ or ‘log’, optional</p>
<blockquote>
<div><p>Sets the scaling of the x-axis.</p>
</div></blockquote>
<p><strong>yscale</strong> : ‘linear’ or ‘log’, optional</p>
<blockquote>
<div><p>Sets the scaling of the y-axis.</p>
</div></blockquote>
<p><strong>axis_center</strong> : (float, float), optional</p>
<blockquote>
<div><p>Tuple of two floats denoting the coordinates of the center or
{‘center’, ‘auto’}</p>
</div></blockquote>
<p><strong>xlim</strong> : (float, float), optional</p>
<blockquote>
<div><p>Denotes the x-axis limits, <code class="docutils literal notranslate"><span class="pre">(min,</span> <span class="pre">max)`</span></code>.</p>
</div></blockquote>
<p><strong>ylim</strong> : (float, float), optional</p>
<blockquote>
<div><p>Denotes the y-axis limits, <code class="docutils literal notranslate"><span class="pre">(min,</span> <span class="pre">max)`</span></code>.</p>
</div></blockquote>
<p><strong>size</strong> : (float, float), optional</p>
<blockquote>
<div><p>A tuple in the form (width, height) in inches to specify the size of
the overall figure. The default value is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>, meaning
the size will be set by the default backend.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">sin</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot_parametric</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;u&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>A parametric plot with a single expression:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot_parametric</span><span class="p">((</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">)),</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-9.png">png</a>, <a class="reference external" href="plotting-9.hires.png">hires.png</a>, <a class="reference external" href="plotting-9.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-9.png" class="plot-directive" src="../_images/plotting-9.png" />
</figure>
<p>A parametric plot with multiple expressions with the same range:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot_parametric</span><span class="p">((</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">)),</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">)),</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: parametric cartesian line: (cos(u), sin(u)) for u over (-10.0, 10.0)</span>
<span class="go">[1]: parametric cartesian line: (u, cos(u)) for u over (-10.0, 10.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-10.png">png</a>, <a class="reference external" href="plotting-10.hires.png">hires.png</a>, <a class="reference external" href="plotting-10.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-10.png" class="plot-directive" src="../_images/plotting-10.png" />
</figure>
<p>A parametric plot with multiple expressions with different ranges
for each curve:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot_parametric</span><span class="p">((</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)),</span>
<span class="gp">... </span>    <span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0)</span>
<span class="go">[1]: parametric cartesian line: (cos(u), u) for u over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-11.png">png</a>, <a class="reference external" href="plotting-11.hires.png">hires.png</a>, <a class="reference external" href="plotting-11.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-11.png" class="plot-directive" src="../_images/plotting-11.png" />
</figure>
<p class="rubric">Notes</p>
<p>The plotting uses an adaptive algorithm which samples recursively to
accurately plot the curve. The adaptive algorithm uses a random point
near the midpoint of two points that has to be further sampled.
Hence, repeating the same plot command can give slightly different
results because of the random sampling.</p>
<p>If there are multiple plots, then the same optional arguments are
applied to all the plots drawn in the same canvas. If you want to
set these options separately, you can index the returned <code class="docutils literal notranslate"><span class="pre">Plot</span></code>
object and set it.</p>
<p>For example, when you specify <code class="docutils literal notranslate"><span class="pre">line_color</span></code> once, it would be
applied simultaneously to both series.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expr1</span> <span class="o">=</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">cos</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="o">*</span><span class="n">u</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">expr2</span> <span class="o">=</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="o">*</span><span class="n">u</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">plot_parametric</span><span class="p">(</span><span class="n">expr1</span><span class="p">,</span> <span class="n">expr2</span><span class="p">,</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">line_color</span><span class="o">=</span><span class="s1">&#39;blue&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-12.png">png</a>, <a class="reference external" href="plotting-12.hires.png">hires.png</a>, <a class="reference external" href="plotting-12.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-12.png" class="plot-directive" src="../_images/plotting-12.png" />
</figure>
<p>If you want to specify the line color for the specific series, you
should index each item and apply the property manually.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">line_color</span> <span class="o">=</span> <span class="s1">&#39;red&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-13.png">png</a>, <a class="reference external" href="plotting-13.hires.png">hires.png</a>, <a class="reference external" href="plotting-13.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-13.png" class="plot-directive" src="../_images/plotting-13.png" />
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.Plot" title="sympy.plotting.plot.Plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Plot</span></code></a>, <a class="reference internal" href="#sympy.plotting.plot.Parametric2DLineSeries" title="sympy.plotting.plot.Parametric2DLineSeries"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Parametric2DLineSeries</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.plot.plot3d">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">plot3d</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L2164-L2301"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.plot3d" title="Permalink to this definition">¶</a></dt>
<dd><p>Plots a 3D surface plot.</p>
<p class="rubric">Usage</p>
<p>Single plot</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d(expr,</span> <span class="pre">range_x,</span> <span class="pre">range_y,</span> <span class="pre">**kwargs)</span></code></p>
<p>If the ranges are not specified, then a default range of (-10, 10) is used.</p>
<p>Multiple plot with the same range.</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d(expr1,</span> <span class="pre">expr2,</span> <span class="pre">range_x,</span> <span class="pre">range_y,</span> <span class="pre">**kwargs)</span></code></p>
<p>If the ranges are not specified, then a default range of (-10, 10) is used.</p>
<p>Multiple plots with different ranges.</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d((expr1,</span> <span class="pre">range_x,</span> <span class="pre">range_y),</span> <span class="pre">(expr2,</span> <span class="pre">range_x,</span> <span class="pre">range_y),</span> <span class="pre">...,</span> <span class="pre">**kwargs)</span></code></p>
<p>Ranges have to be specified for every expression.</p>
<p>Default range may change in the future if a more advanced default range
detection algorithm is implemented.</p>
<p class="rubric">Arguments</p>
<p><code class="docutils literal notranslate"><span class="pre">expr</span></code> : Expression representing the function along x.</p>
<p><code class="docutils literal notranslate"><span class="pre">range_x</span></code>: (x, 0, 5), A 3-tuple denoting the range of the x
variable.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">range_y</span></code>: (y, 0, 5), A 3-tuple denoting the range of the y</dt><dd><p>variable.</p>
</dd>
</dl>
<p class="rubric">Keyword Arguments</p>
<p>Arguments for <code class="docutils literal notranslate"><span class="pre">SurfaceOver2DRangeSeries</span></code> class:</p>
<p><code class="docutils literal notranslate"><span class="pre">nb_of_points_x</span></code>: int. The x range is sampled uniformly at
<code class="docutils literal notranslate"><span class="pre">nb_of_points_x</span></code> of points.</p>
<p><code class="docutils literal notranslate"><span class="pre">nb_of_points_y</span></code>: int. The y range is sampled uniformly at
<code class="docutils literal notranslate"><span class="pre">nb_of_points_y</span></code> of points.</p>
<p>Aesthetics:</p>
<p><code class="docutils literal notranslate"><span class="pre">surface_color</span></code>: Function which returns a float. Specifies the color for
the surface of the plot. See <code class="docutils literal notranslate"><span class="pre">sympy.plotting.Plot</span></code> for more details.</p>
<p>If there are multiple plots, then the same series arguments are applied to
all the plots. If you want to set these options separately, you can index
the returned <code class="docutils literal notranslate"><span class="pre">Plot</span></code> object and set it.</p>
<p>Arguments for <code class="docutils literal notranslate"><span class="pre">Plot</span></code> class:</p>
<p><code class="docutils literal notranslate"><span class="pre">title</span></code> : str. Title of the plot.
<code class="docutils literal notranslate"><span class="pre">size</span></code> : (float, float), optional
A tuple in the form (width, height) in inches to specify the size of the
overall figure. The default value is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>, meaning the size will
be set by the default backend.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot3d</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Single plot</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot3d</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-15.png">png</a>, <a class="reference external" href="plotting-15.hires.png">hires.png</a>, <a class="reference external" href="plotting-15.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-15.png" class="plot-directive" src="../_images/plotting-15.png" />
</figure>
<p>Multiple plots with same range</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot3d</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)</span>
<span class="go">[1]: cartesian surface: -x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-16.png">png</a>, <a class="reference external" href="plotting-16.hires.png">hires.png</a>, <a class="reference external" href="plotting-16.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-16.png" class="plot-directive" src="../_images/plotting-16.png" />
</figure>
<p>Multiple plots with different ranges.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot3d</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)),</span>
<span class="gp">... </span>    <span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">)))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: cartesian surface: x**2 + y**2 for x over (-5.0, 5.0) and y over (-5.0, 5.0)</span>
<span class="go">[1]: cartesian surface: x*y for x over (-3.0, 3.0) and y over (-3.0, 3.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-17.png">png</a>, <a class="reference external" href="plotting-17.hires.png">hires.png</a>, <a class="reference external" href="plotting-17.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-17.png" class="plot-directive" src="../_images/plotting-17.png" />
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.Plot" title="sympy.plotting.plot.Plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Plot</span></code></a>, <a class="reference internal" href="#sympy.plotting.plot.SurfaceOver2DRangeSeries" title="sympy.plotting.plot.SurfaceOver2DRangeSeries"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SurfaceOver2DRangeSeries</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.plot.plot3d_parametric_line">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">plot3d_parametric_line</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L2040-L2161"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.plot3d_parametric_line" title="Permalink to this definition">¶</a></dt>
<dd><p>Plots a 3D parametric line plot.</p>
<p class="rubric">Usage</p>
<p>Single plot:</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d_parametric_line(expr_x,</span> <span class="pre">expr_y,</span> <span class="pre">expr_z,</span> <span class="pre">range,</span> <span class="pre">**kwargs)</span></code></p>
<p>If the range is not specified, then a default range of (-10, 10) is used.</p>
<p>Multiple plots.</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d_parametric_line((expr_x,</span> <span class="pre">expr_y,</span> <span class="pre">expr_z,</span> <span class="pre">range),</span> <span class="pre">...,</span> <span class="pre">**kwargs)</span></code></p>
<p>Ranges have to be specified for every expression.</p>
<p>Default range may change in the future if a more advanced default range
detection algorithm is implemented.</p>
<p class="rubric">Arguments</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_x</span></code> : Expression representing the function along x.</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_y</span></code> : Expression representing the function along y.</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_z</span></code> : Expression representing the function along z.</p>
<p><code class="docutils literal notranslate"><span class="pre">range</span></code>: <code class="docutils literal notranslate"><span class="pre">(u,</span> <span class="pre">0,</span> <span class="pre">5)</span></code>, A 3-tuple denoting the range of the parameter
variable.</p>
<p class="rubric">Keyword Arguments</p>
<p>Arguments for <code class="docutils literal notranslate"><span class="pre">Parametric3DLineSeries</span></code> class.</p>
<p><code class="docutils literal notranslate"><span class="pre">nb_of_points</span></code>: The range is uniformly sampled at <code class="docutils literal notranslate"><span class="pre">nb_of_points</span></code>
number of points.</p>
<p>Aesthetics:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">line_color</span></code>: string, or float, or function, optional</dt><dd><p>Specifies the color for the plot.
See <code class="docutils literal notranslate"><span class="pre">Plot</span></code> to see how to set color for the plots.
Note that by setting <code class="docutils literal notranslate"><span class="pre">line_color</span></code>, it would be applied simultaneously
to all the series.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">label</span></code>: str</dt><dd><p>The label to the plot. It will be used when called with <code class="docutils literal notranslate"><span class="pre">legend=True</span></code>
to denote the function with the given label in the plot.</p>
</dd>
</dl>
<p>If there are multiple plots, then the same series arguments are applied to
all the plots. If you want to set these options separately, you can index
the returned <code class="docutils literal notranslate"><span class="pre">Plot</span></code> object and set it.</p>
<p>Arguments for <code class="docutils literal notranslate"><span class="pre">Plot</span></code> class.</p>
<p><code class="docutils literal notranslate"><span class="pre">title</span></code> : str. Title of the plot.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">size</span></code><span class="classifier">(float, float), optional</span></dt><dd><p>A tuple in the form (width, height) in inches to specify the size of
the overall figure. The default value is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>, meaning
the size will be set by the default backend.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">sin</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot3d_parametric_line</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;u&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Single plot.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot3d_parametric_line</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-19.png">png</a>, <a class="reference external" href="plotting-19.hires.png">hires.png</a>, <a class="reference external" href="plotting-19.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-19.png" class="plot-directive" src="../_images/plotting-19.png" />
</figure>
<p>Multiple plots.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot3d_parametric_line</span><span class="p">((</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)),</span>
<span class="gp">... </span>    <span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">u</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0)</span>
<span class="go">[1]: 3D parametric cartesian line: (sin(u), u**2, u) for u over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-20.png">png</a>, <a class="reference external" href="plotting-20.hires.png">hires.png</a>, <a class="reference external" href="plotting-20.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-20.png" class="plot-directive" src="../_images/plotting-20.png" />
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.Plot" title="sympy.plotting.plot.Plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Plot</span></code></a>, <a class="reference internal" href="#sympy.plotting.plot.Parametric3DLineSeries" title="sympy.plotting.plot.Parametric3DLineSeries"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Parametric3DLineSeries</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.plot.plot3d_parametric_surface">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">plot3d_parametric_surface</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L2304-L2412"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.plot3d_parametric_surface" title="Permalink to this definition">¶</a></dt>
<dd><p>Plots a 3D parametric surface plot.</p>
<p class="rubric">Explanation</p>
<p>Single plot.</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d_parametric_surface(expr_x,</span> <span class="pre">expr_y,</span> <span class="pre">expr_z,</span> <span class="pre">range_u,</span> <span class="pre">range_v,</span> <span class="pre">**kwargs)</span></code></p>
<p>If the ranges is not specified, then a default range of (-10, 10) is used.</p>
<p>Multiple plots.</p>
<p><code class="docutils literal notranslate"><span class="pre">plot3d_parametric_surface((expr_x,</span> <span class="pre">expr_y,</span> <span class="pre">expr_z,</span> <span class="pre">range_u,</span> <span class="pre">range_v),</span> <span class="pre">...,</span> <span class="pre">**kwargs)</span></code></p>
<p>Ranges have to be specified for every expression.</p>
<p>Default range may change in the future if a more advanced default range
detection algorithm is implemented.</p>
<p class="rubric">Arguments</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_x</span></code>: Expression representing the function along <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_y</span></code>: Expression representing the function along <code class="docutils literal notranslate"><span class="pre">y</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">expr_z</span></code>: Expression representing the function along <code class="docutils literal notranslate"><span class="pre">z</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">range_u</span></code>: <code class="docutils literal notranslate"><span class="pre">(u,</span> <span class="pre">0,</span> <span class="pre">5)</span></code>,  A 3-tuple denoting the range of the <code class="docutils literal notranslate"><span class="pre">u</span></code>
variable.</p>
<p><code class="docutils literal notranslate"><span class="pre">range_v</span></code>: <code class="docutils literal notranslate"><span class="pre">(v,</span> <span class="pre">0,</span> <span class="pre">5)</span></code>,  A 3-tuple denoting the range of the v
variable.</p>
<p class="rubric">Keyword Arguments</p>
<p>Arguments for <code class="docutils literal notranslate"><span class="pre">ParametricSurfaceSeries</span></code> class:</p>
<p><code class="docutils literal notranslate"><span class="pre">nb_of_points_u</span></code>: int. The <code class="docutils literal notranslate"><span class="pre">u</span></code> range is sampled uniformly at
<code class="docutils literal notranslate"><span class="pre">nb_of_points_v</span></code> of points</p>
<p><code class="docutils literal notranslate"><span class="pre">nb_of_points_y</span></code>: int. The <code class="docutils literal notranslate"><span class="pre">v</span></code> range is sampled uniformly at
<code class="docutils literal notranslate"><span class="pre">nb_of_points_y</span></code> of points</p>
<p>Aesthetics:</p>
<p><code class="docutils literal notranslate"><span class="pre">surface_color</span></code>: Function which returns a float. Specifies the color for
the surface of the plot. See <code class="docutils literal notranslate"><span class="pre">sympy.plotting.Plot</span></code> for more details.</p>
<p>If there are multiple plots, then the same series arguments are applied for
all the plots. If you want to set these options separately, you can index
the returned <code class="docutils literal notranslate"><span class="pre">Plot</span></code> object and set it.</p>
<p>Arguments for <code class="docutils literal notranslate"><span class="pre">Plot</span></code> class:</p>
<p><code class="docutils literal notranslate"><span class="pre">title</span></code> : str. Title of the plot.
<code class="docutils literal notranslate"><span class="pre">size</span></code> : (float, float), optional
A tuple in the form (width, height) in inches to specify the size of the
overall figure. The default value is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>, meaning the size will
be set by the default backend.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">sin</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot3d_parametric_surface</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span><span class="p">,</span> <span class="n">v</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;u v&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Single plot.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">plot3d_parametric_surface</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span> <span class="o">+</span> <span class="n">v</span><span class="p">),</span> <span class="n">sin</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="n">v</span><span class="p">),</span> <span class="n">u</span> <span class="o">-</span> <span class="n">v</span><span class="p">,</span>
<span class="gp">... </span>    <span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Plot object containing:</span>
<span class="go">[0]: parametric cartesian surface: (cos(u + v), sin(u - v), u - v) for u over (-5.0, 5.0) and v over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-22.png">png</a>, <a class="reference external" href="plotting-22.hires.png">hires.png</a>, <a class="reference external" href="plotting-22.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-22.png" class="plot-directive" src="../_images/plotting-22.png" />
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.Plot" title="sympy.plotting.plot.Plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Plot</span></code></a>, <a class="reference internal" href="#sympy.plotting.plot.ParametricSurfaceSeries" title="sympy.plotting.plot.ParametricSurfaceSeries"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ParametricSurfaceSeries</span></code></a></p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.plot_implicit.plot_implicit">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot_implicit.</span></span><span class="sig-name descname"><span class="pre">plot_implicit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_var</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_var</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adaptive</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">depth</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">points</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">300</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">line_color</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'blue'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot_implicit.py#L209-L428"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot_implicit.plot_implicit" title="Permalink to this definition">¶</a></dt>
<dd><p>A plot function to plot implicit equations / inequalities.</p>
<p class="rubric">Arguments</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">expr</span></code> : The equation / inequality that is to be plotted.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">x_var</span></code> (optional) : symbol to plot on x-axis or tuple giving symbol
and range as <code class="docutils literal notranslate"><span class="pre">(symbol,</span> <span class="pre">xmin,</span> <span class="pre">xmax)</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">y_var</span></code> (optional) : symbol to plot on y-axis or tuple giving symbol
and range as <code class="docutils literal notranslate"><span class="pre">(symbol,</span> <span class="pre">ymin,</span> <span class="pre">ymax)</span></code></p></li>
</ul>
<p>If neither <code class="docutils literal notranslate"><span class="pre">x_var</span></code> nor <code class="docutils literal notranslate"><span class="pre">y_var</span></code> are given then the free symbols in the
expression will be assigned in the order they are sorted.</p>
<p>The following keyword arguments can also be used:</p>
<ul class="simple">
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">adaptive</span></code> Boolean. The default value is set to True. It has to be</dt><dd><p>set to False if you want to use a mesh grid.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">depth</span></code> integer. The depth of recursion for adaptive mesh grid.</dt><dd><p>Default value is 0. Takes value in the range (0, 4).</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">points</span></code> integer. The number of points if adaptive mesh grid is not</dt><dd><p>used. Default value is 300.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">show</span></code> Boolean. Default value is True. If set to False, the plot will</dt><dd><p>not be shown. See <code class="docutils literal notranslate"><span class="pre">Plot</span></code> for further information.</p>
</dd>
</dl>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">title</span></code> string. The title for the plot.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xlabel</span></code> string. The label for the x-axis</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ylabel</span></code> string. The label for the y-axis</p></li>
</ul>
<p>Aesthetics options:</p>
<ul class="simple">
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">line_color</span></code>: float or string. Specifies the color for the plot.</dt><dd><p>See <code class="docutils literal notranslate"><span class="pre">Plot</span></code> to see how to set color for the plots.
Default value is “Blue”</p>
</dd>
</dl>
</li>
</ul>
<p>plot_implicit, by default, uses interval arithmetic to plot functions. If
the expression cannot be plotted using interval arithmetic, it defaults to
a generating a contour using a mesh grid of fixed number of points. By
setting adaptive to False, you can force plot_implicit to use the mesh
grid. The mesh grid method can be effective when adaptive plotting using
interval arithmetic, fails to plot with small line width.</p>
<p class="rubric">Examples</p>
<p>Plot expressions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">plot_implicit</span><span class="p">,</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">Eq</span><span class="p">,</span> <span class="n">And</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Without any ranges for the symbols in the expression:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span><span class="n">Eq</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-24.png">png</a>, <a class="reference external" href="plotting-24.hires.png">hires.png</a>, <a class="reference external" href="plotting-24.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-24.png" class="plot-directive" src="../_images/plotting-24.png" />
</figure>
<p>With the range for the symbols:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p2</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span>
<span class="gp">... </span>    <span class="n">Eq</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-25.png">png</a>, <a class="reference external" href="plotting-25.hires.png">hires.png</a>, <a class="reference external" href="plotting-25.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-25.png" class="plot-directive" src="../_images/plotting-25.png" />
</figure>
<p>With depth of recursion as argument:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p3</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span>
<span class="gp">... </span>    <span class="n">Eq</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="n">depth</span> <span class="o">=</span> <span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-26.png">png</a>, <a class="reference external" href="plotting-26.hires.png">hires.png</a>, <a class="reference external" href="plotting-26.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-26.png" class="plot-directive" src="../_images/plotting-26.png" />
</figure>
<p>Using mesh grid and not using adaptive meshing:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p4</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span>
<span class="gp">... </span>    <span class="n">Eq</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
<span class="gp">... </span>    <span class="n">adaptive</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-27.png">png</a>, <a class="reference external" href="plotting-27.hires.png">hires.png</a>, <a class="reference external" href="plotting-27.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-27.png" class="plot-directive" src="../_images/plotting-27.png" />
</figure>
<p>Using mesh grid without using adaptive meshing with number of points
specified:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p5</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span>
<span class="gp">... </span>    <span class="n">Eq</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
<span class="gp">... </span>    <span class="n">adaptive</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">points</span><span class="o">=</span><span class="mi">400</span><span class="p">)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-28.png">png</a>, <a class="reference external" href="plotting-28.hires.png">hires.png</a>, <a class="reference external" href="plotting-28.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-28.png" class="plot-directive" src="../_images/plotting-28.png" />
</figure>
<p>Plotting regions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p6</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span><span class="n">y</span> <span class="o">&gt;</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-29.png">png</a>, <a class="reference external" href="plotting-29.hires.png">hires.png</a>, <a class="reference external" href="plotting-29.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-29.png" class="plot-directive" src="../_images/plotting-29.png" />
</figure>
<p>Plotting Using boolean conjunctions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p7</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span><span class="n">And</span><span class="p">(</span><span class="n">y</span> <span class="o">&gt;</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">&gt;</span> <span class="o">-</span><span class="n">x</span><span class="p">))</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-30.png">png</a>, <a class="reference external" href="plotting-30.hires.png">hires.png</a>, <a class="reference external" href="plotting-30.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-30.png" class="plot-directive" src="../_images/plotting-30.png" />
</figure>
<p>When plotting an expression with a single variable (y - 1, for example),
specify the x or the y variable explicitly:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p8</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span><span class="n">y</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">y_var</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p9</span> <span class="o">=</span> <span class="n">plot_implicit</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x_var</span><span class="o">=</span><span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<figure class="align-default" id="id3">
<img alt="../_images/plotting-31_00.png" class="plot-directive" src="../_images/plotting-31_00.png" />
<figcaption>
<p><span class="caption-text">(<a class="reference external" href="plotting-31_00.png">png</a>, <a class="reference external" href="plotting-31_00.hires.png">hires.png</a>, <a class="reference external" href="plotting-31_00.pdf">pdf</a>)</span><a class="headerlink" href="#id3" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
<figure class="align-default" id="id4">
<img alt="../_images/plotting-31_01.png" class="plot-directive" src="../_images/plotting-31_01.png" />
<figcaption>
<p><span class="caption-text">(<a class="reference external" href="plotting-31_01.png">png</a>, <a class="reference external" href="plotting-31_01.hires.png">hires.png</a>, <a class="reference external" href="plotting-31_01.pdf">pdf</a>)</span><a class="headerlink" href="#id4" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
</dd></dl>

</section>
<section id="plotgrid-class">
<h2>PlotGrid Class<a class="headerlink" href="#plotgrid-class" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.PlotGrid">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">PlotGrid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nrows</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ncolumns</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">show</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L332-L470"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.PlotGrid" title="Permalink to this definition">¶</a></dt>
<dd><p>This class helps to plot subplots from already created sympy plots
in a single figure.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">plot</span><span class="p">,</span> <span class="n">plot3d</span><span class="p">,</span> <span class="n">PlotGrid</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x, y&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span> <span class="o">=</span> <span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p2</span> <span class="o">=</span> <span class="n">plot</span><span class="p">((</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">6</span><span class="p">,</span> <span class="mi">6</span><span class="p">)),</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p3</span> <span class="o">=</span> <span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p4</span> <span class="o">=</span> <span class="n">plot3d</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
</pre></div>
</div>
<figure class="align-default" id="id5">
<img alt="../_images/plotting-32_00.png" class="plot-directive" src="../_images/plotting-32_00.png" />
<figcaption>
<p><span class="caption-text">(<a class="reference external" href="plotting-32_00.png">png</a>, <a class="reference external" href="plotting-32_00.hires.png">hires.png</a>, <a class="reference external" href="plotting-32_00.pdf">pdf</a>)</span><a class="headerlink" href="#id5" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
<figure class="align-default" id="id6">
<img alt="../_images/plotting-32_01.png" class="plot-directive" src="../_images/plotting-32_01.png" />
<figcaption>
<p><span class="caption-text">(<a class="reference external" href="plotting-32_01.png">png</a>, <a class="reference external" href="plotting-32_01.hires.png">hires.png</a>, <a class="reference external" href="plotting-32_01.pdf">pdf</a>)</span><a class="headerlink" href="#id6" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
<figure class="align-default" id="id7">
<img alt="../_images/plotting-32_02.png" class="plot-directive" src="../_images/plotting-32_02.png" />
<figcaption>
<p><span class="caption-text">(<a class="reference external" href="plotting-32_02.png">png</a>, <a class="reference external" href="plotting-32_02.hires.png">hires.png</a>, <a class="reference external" href="plotting-32_02.pdf">pdf</a>)</span><a class="headerlink" href="#id7" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
<figure class="align-default" id="id8">
<img alt="../_images/plotting-32_03.png" class="plot-directive" src="../_images/plotting-32_03.png" />
<figcaption>
<p><span class="caption-text">(<a class="reference external" href="plotting-32_03.png">png</a>, <a class="reference external" href="plotting-32_03.hires.png">hires.png</a>, <a class="reference external" href="plotting-32_03.pdf">pdf</a>)</span><a class="headerlink" href="#id8" title="Permalink to this image">¶</a></p>
</figcaption>
</figure>
<p>Plotting vertically in a single line:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PlotGrid</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span> <span class="p">,</span> <span class="n">p1</span><span class="p">,</span> <span class="n">p2</span><span class="p">)</span>
<span class="go">PlotGrid object containing:</span>
<span class="go">Plot[0]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x for x over (-5.0, 5.0)</span>
<span class="go">[1]: cartesian line: x**2 for x over (-5.0, 5.0)</span>
<span class="go">[2]: cartesian line: x**3 for x over (-5.0, 5.0)</span>
<span class="go">Plot[1]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-6.0, 6.0)</span>
<span class="go">[1]: cartesian line: x for x over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-33.png">png</a>, <a class="reference external" href="plotting-33.hires.png">hires.png</a>, <a class="reference external" href="plotting-33.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-33.png" class="plot-directive" src="../_images/plotting-33.png" />
</figure>
<p>Plotting horizontally in a single line:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PlotGrid</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span> <span class="p">,</span> <span class="n">p2</span><span class="p">,</span> <span class="n">p3</span><span class="p">,</span> <span class="n">p4</span><span class="p">)</span>
<span class="go">PlotGrid object containing:</span>
<span class="go">Plot[0]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-6.0, 6.0)</span>
<span class="go">[1]: cartesian line: x for x over (-5.0, 5.0)</span>
<span class="go">Plot[1]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x**3 for x over (-5.0, 5.0)</span>
<span class="go">Plot[2]:Plot object containing:</span>
<span class="go">[0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-34.png">png</a>, <a class="reference external" href="plotting-34.hires.png">hires.png</a>, <a class="reference external" href="plotting-34.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-34.png" class="plot-directive" src="../_images/plotting-34.png" />
</figure>
<p>Plotting in a grid form:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">PlotGrid</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">p1</span><span class="p">,</span> <span class="n">p2</span> <span class="p">,</span><span class="n">p3</span><span class="p">,</span> <span class="n">p4</span><span class="p">)</span>
<span class="go">PlotGrid object containing:</span>
<span class="go">Plot[0]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x for x over (-5.0, 5.0)</span>
<span class="go">[1]: cartesian line: x**2 for x over (-5.0, 5.0)</span>
<span class="go">[2]: cartesian line: x**3 for x over (-5.0, 5.0)</span>
<span class="go">Plot[1]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x**2 for x over (-6.0, 6.0)</span>
<span class="go">[1]: cartesian line: x for x over (-5.0, 5.0)</span>
<span class="go">Plot[2]:Plot object containing:</span>
<span class="go">[0]: cartesian line: x**3 for x over (-5.0, 5.0)</span>
<span class="go">Plot[3]:Plot object containing:</span>
<span class="go">[0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)</span>
</pre></div>
</div>
<p>(<a class="reference external" href="plotting-35.png">png</a>, <a class="reference external" href="plotting-35.hires.png">hires.png</a>, <a class="reference external" href="plotting-35.pdf">pdf</a>)</p>
<figure class="align-default">
<img alt="../_images/plotting-35.png" class="plot-directive" src="../_images/plotting-35.png" />
</figure>
</dd></dl>

</section>
<section id="series-classes">
<h2>Series Classes<a class="headerlink" href="#series-classes" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.BaseSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">BaseSeries</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L479-L553"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.BaseSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for the data objects containing stuff to be plotted.</p>
<p class="rubric">Explanation</p>
<p>The backend should check if it supports the data series that it’s given.
(eg TextBackend supports only LineOver1DRange).
It’s the backend responsibility to know how to use the class of
data series that it’s given.</p>
<p>Some data series classes are grouped (using a class attribute like is_2Dline)
according to the api they present (based only on convention). The backend is
not obliged to use that api (eg. The LineOver1DRange belongs to the
is_2Dline group and presents the get_points method, but the
TextBackend does not use the get_points method).</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.Line2DBaseSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">Line2DBaseSeries</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L557-L634"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Line2DBaseSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>A base class for 2D lines.</p>
<ul class="simple">
<li><p>adding the label, steps and only_integers options</p></li>
<li><p>making is_2Dline true</p></li>
<li><p>defining get_segments and get_color_array</p></li>
</ul>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.Line2DBaseSeries.get_data">
<span class="sig-name descname"><span class="pre">get_data</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L576-L602"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Line2DBaseSeries.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Return lists of coordinates for plotting the line.</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>x: list</p>
<blockquote>
<div><blockquote>
<div><p>List of x-coordinates</p>
</div></blockquote>
<dl class="simple">
<dt>y: list</dt><dd><p>List of y-coordinates</p>
</dd>
<dt>y: list</dt><dd><p>List of z-coordinates in case of Parametric3DLineSeries</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.LineOver1DRangeSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">LineOver1DRangeSeries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L654-L786"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.LineOver1DRangeSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation for a line consisting of a SymPy expression over a range.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.LineOver1DRangeSeries.get_points">
<span class="sig-name descname"><span class="pre">get_points</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L674-L768"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.LineOver1DRangeSeries.get_points" title="Permalink to this definition">¶</a></dt>
<dd><p>Return lists of coordinates for plotting. Depending on the
<span class="math notranslate nohighlight">\(adaptive\)</span> option, this function will either use an adaptive algorithm
or it will uniformly sample the expression over the provided range.</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>x: list</p>
<blockquote>
<div><blockquote>
<div><p>List of x-coordinates</p>
</div></blockquote>
<dl class="simple">
<dt>y: list</dt><dd><p>List of y-coordinates</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Explanation</p>
<p>The adaptive sampling is done by recursively checking if three
points are almost collinear. If they are not collinear, then more
points are added between those points.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r643"><span class="brackets"><a class="fn-backref" href="#id1">R643</a></span></dt>
<dd><p>Adaptive polygonal approximation of parametric curves,
Luiz Henrique de Figueiredo.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.Parametric2DLineSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">Parametric2DLineSeries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expr_y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L788-L925"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Parametric2DLineSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation for a line consisting of two parametric sympy expressions
over a range.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.Parametric2DLineSeries.get_points">
<span class="sig-name descname"><span class="pre">get_points</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L825-L925"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Parametric2DLineSeries.get_points" title="Permalink to this definition">¶</a></dt>
<dd><p>Return lists of coordinates for plotting. Depending on the
<span class="math notranslate nohighlight">\(adaptive\)</span> option, this function will either use an adaptive algorithm
or it will uniformly sample the expression over the provided range.</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>x: list</p>
<blockquote>
<div><blockquote>
<div><p>List of x-coordinates</p>
</div></blockquote>
<dl class="simple">
<dt>y: list</dt><dd><p>List of y-coordinates</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Explanation</p>
<p>The adaptive sampling is done by recursively checking if three
points are almost collinear. If they are not collinear, then more
points are added between those points.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r644"><span class="brackets"><a class="fn-backref" href="#id2">R644</a></span></dt>
<dd><p>Adaptive polygonal approximation of parametric curves,
Luiz Henrique de Figueiredo.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.Line3DBaseSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">Line3DBaseSeries</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L929-L939"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Line3DBaseSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>A base class for 3D lines.</p>
<p>Most of the stuff is derived from Line2DBaseSeries.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.Parametric3DLineSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">Parametric3DLineSeries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expr_y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expr_z</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L942-L992"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.Parametric3DLineSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation for a 3D line consisting of three parametric sympy
expressions and a range.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.SurfaceBaseSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">SurfaceBaseSeries</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L996-L1028"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.SurfaceBaseSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>A base class for 3D surfaces.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.SurfaceOver2DRangeSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">SurfaceOver2DRangeSeries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end_y</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1031-L1070"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.SurfaceOver2DRangeSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation for a 3D surface consisting of a sympy expression and 2D
range.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.ParametricSurfaceSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">ParametricSurfaceSeries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expr_y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expr_z</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end_u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end_v</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1073-L1138"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.ParametricSurfaceSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation for a 3D surface consisting of three parametric sympy
expressions and a range.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot_implicit.ImplicitSeries">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot_implicit.</span></span><span class="sig-name descname"><span class="pre">ImplicitSeries</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end_x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">var_start_end_y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">has_equality</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_interval_math</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">depth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nb_of_points</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">line_color</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot_implicit.py#L46-L206"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot_implicit.ImplicitSeries" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation for Implicit plot</p>
</dd></dl>

</section>
<section id="backends">
<h2>Backends<a class="headerlink" href="#backends" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.BaseBackend">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">BaseBackend</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parent</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1189-L1255"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.BaseBackend" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for all backends. A backend represents the plotting library,
which implements the necessary functionalities in order to use SymPy
plotting functions.</p>
<p>How the plotting module works:</p>
<ol class="arabic simple">
<li><dl class="simple">
<dt>Whenever a plotting function is called, the provided expressions are</dt><dd><p>processed and a list of instances of the <span class="math notranslate nohighlight">\(BaseSeries\)</span> class is created,
containing the necessary information to plot the expressions (eg the
expression, ranges, series name, …). Eventually, these objects will
generate the numerical data to be plotted.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>A Plot object is instantiated, which stores the list of series and the</dt><dd><p>main attributes of the plot (eg axis labels, title, …).</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>When the “show” command is executed, a new backend is instantiated,</dt><dd><p>which loops through each series object to generate and plot the
numerical data. The backend is also going to set the axis labels, title,
…, according to the values stored in the Plot instance.</p>
</dd>
</dl>
</li>
</ol>
<p>The backend should check if it supports the data series that it’s given
(eg TextBackend supports only LineOver1DRange).</p>
<p>It’s the backend responsibility to know how to use the class of data series
that it’s given. Note that the current implementation of the <span class="math notranslate nohighlight">\(*Series\)</span>
classes is “matplotlib-centric”: the numerical data returned by the
<span class="math notranslate nohighlight">\(get_points\)</span> and <span class="math notranslate nohighlight">\(get_meshes\)</span> methods is meant to be used directly by
Matplotlib. Therefore, the new backend will have to pre-process the
numerical data to make it compatible with the chosen plotting library.
Keep in mind that future SymPy versions may improve the <span class="math notranslate nohighlight">\(*Series\)</span> classes in
order to return numerical data “non-matplotlib-centric”, hence if you code
a new backend you have the responsibility to check if its working on each
SymPy release.</p>
<p>Please, explore the <span class="math notranslate nohighlight">\(MatplotlibBackend\)</span> source code to understand how a
backend should be coded.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.plotting.plot.MatplotlibBackend" title="sympy.plotting.plot.MatplotlibBackend"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MatplotlibBackend</span></code></a></p>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.MatplotlibBackend">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">MatplotlibBackend</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parent</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1260-L1538"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.MatplotlibBackend" title="Permalink to this definition">¶</a></dt>
<dd><p>This class implements the functionalities to use Matplotlib with SymPy
plotting functions.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.MatplotlibBackend.get_segments">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">get_segments</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1307-L1331"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.MatplotlibBackend.get_segments" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert two list of coordinates to a list of segments to be used
with Matplotlib’s LineCollection.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x: list</strong></p>
<blockquote>
<div><blockquote>
<div><p>List of x-coordinates</p>
</div></blockquote>
<dl class="simple">
<dt>y: list</dt><dd><p>List of y-coordinates</p>
</dd>
<dt>z: list</dt><dd><p>List of z-coordinates for a 3D line.</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.plotting.plot.MatplotlibBackend.process_series">
<span class="sig-name descname"><span class="pre">process_series</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1506-L1520"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.MatplotlibBackend.process_series" title="Permalink to this definition">¶</a></dt>
<dd><p>Iterates over every <code class="docutils literal notranslate"><span class="pre">Plot</span></code> object and further calls
_process_series()</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.plotting.plot.TextBackend">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.plotting.plot.</span></span><span class="sig-name descname"><span class="pre">TextBackend</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parent</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/plot.py#L1541-L1559"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.plot.TextBackend" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</section>
<section id="module-sympy.plotting.pygletplot">
<span id="pyglet-plotting"></span><h2>Pyglet Plotting<a class="headerlink" href="#module-sympy.plotting.pygletplot" title="Permalink to this headline">¶</a></h2>
<p>This is the documentation for the old plotting module that uses pyglet.
This module has some limitations and is not actively developed anymore.
For an alternative you can look at the new plotting module.</p>
<p>The pyglet plotting module can do nice 2D and 3D plots that can be
controlled by console commands as well as keyboard and mouse, with
the only dependency being <code class="docutils literal notranslate"><span class="pre">pyglet</span></code>.</p>
<p>Here is the simplest usage:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">var</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting.pygletplot</span> <span class="kn">import</span> <span class="n">PygletPlot</span> <span class="k">as</span> <span class="n">Plot</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">var</span><span class="p">(</span><span class="s1">&#39;x y z&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span><span class="o">-</span><span class="n">y</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>To see lots of plotting examples, see <code class="docutils literal notranslate"><span class="pre">examples/pyglet_plotting.py</span></code> and try running
it in interactive mode (python -i plotting.py):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python -i examples/pyglet_plotting.py
</pre></div>
</div>
<p>And type for instance <code class="docutils literal notranslate"><span class="pre">example(7)</span></code> or <code class="docutils literal notranslate"><span class="pre">example(11)</span></code>.</p>
<p>See also the <a class="reference external" href="https://github.com/sympy/sympy/wiki/Plotting-capabilities">Plotting Module</a>
wiki page for screenshots.</p>
</section>
<section id="plot-window-controls">
<h2>Plot Window Controls<a class="headerlink" href="#plot-window-controls" title="Permalink to this headline">¶</a></h2>
<table class="docutils align-default">
<colgroup>
<col style="width: 35%" />
<col style="width: 65%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Camera</p></th>
<th class="head"><p>Keys</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Sensitivity Modifier</p></td>
<td><p>SHIFT</p></td>
</tr>
<tr class="row-odd"><td><p>Zoom</p></td>
<td><p>R and F, Page Up and Down, Numpad + and -</p></td>
</tr>
<tr class="row-even"><td><p>Rotate View X,Y axis</p></td>
<td><p>Arrow Keys, A,S,D,W, Numpad 4,6,8,2</p></td>
</tr>
<tr class="row-odd"><td><p>Rotate View Z axis</p></td>
<td><p>Q and E, Numpad 7 and 9</p></td>
</tr>
<tr class="row-even"><td><p>Rotate Ordinate Z axis</p></td>
<td><p>Z and C, Numpad 1 and 3</p></td>
</tr>
<tr class="row-odd"><td><p>View XY</p></td>
<td><p>F1</p></td>
</tr>
<tr class="row-even"><td><p>View XZ</p></td>
<td><p>F2</p></td>
</tr>
<tr class="row-odd"><td><p>View YZ</p></td>
<td><p>F3</p></td>
</tr>
<tr class="row-even"><td><p>View Perspective</p></td>
<td><p>F4</p></td>
</tr>
<tr class="row-odd"><td><p>Reset</p></td>
<td><p>X, Numpad 5</p></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 73%" />
<col style="width: 27%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Axes</p></th>
<th class="head"><p>Keys</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Toggle Visible</p></td>
<td><p>F5</p></td>
</tr>
<tr class="row-odd"><td><p>Toggle Colors</p></td>
<td><p>F6</p></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 73%" />
<col style="width: 27%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Window</p></th>
<th class="head"><p>Keys</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Close</p></td>
<td><p>ESCAPE</p></td>
</tr>
<tr class="row-odd"><td><p>Screenshot</p></td>
<td><p>F8</p></td>
</tr>
</tbody>
</table>
<p>The mouse can be used to rotate, zoom, and translate by dragging the left, middle,
and right mouse buttons respectively.</p>
</section>
<section id="coordinate-modes">
<h2>Coordinate Modes<a class="headerlink" href="#coordinate-modes" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">Plot</span></code> supports several curvilinear coordinate modes, and they are independent
for each plotted function. You can specify a coordinate mode explicitly with
the ‘mode’ named argument, but it can be automatically determined for cartesian
or parametric plots, and therefore must only be specified for polar,
cylindrical, and spherical modes.</p>
<p>Specifically, <code class="docutils literal notranslate"><span class="pre">Plot(function</span> <span class="pre">arguments)</span></code> and <code class="docutils literal notranslate"><span class="pre">Plot.__setitem__(i,</span> <span class="pre">function</span>
<span class="pre">arguments)</span></code> (accessed using array-index syntax on the <code class="docutils literal notranslate"><span class="pre">Plot</span></code> instance) will
interpret your arguments as a cartesian plot if you provide one function and a
parametric plot if you provide two or three functions. Similarly, the arguments
will be interpreted as a curve is one variable is used, and a surface if two
are used.</p>
<p>Supported mode names by number of variables:</p>
<ul class="simple">
<li><p>1 (curves): parametric, cartesian, polar</p></li>
<li><p>2 (surfaces): parametric, cartesian, cylindrical, spherical</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;mode=spherical; color=zfade4&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Note that function parameters are given as option strings of the form
“key1=value1; key2 = value2” (spaces are truncated). Keyword arguments given
directly to plot apply to the plot itself.</p>
</section>
<section id="specifying-intervals-for-variables">
<h2>Specifying Intervals for Variables<a class="headerlink" href="#specifying-intervals-for-variables" title="Permalink to this headline">¶</a></h2>
<p>The basic format for variable intervals is [var, min, max, steps]. However, the
syntax is quite flexible, and arguments not specified are taken from the
defaults for the current coordinate mode:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span> <span class="c1"># implies [x,-5,5,100]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">[],</span> <span class="p">[])</span> <span class="c1"># [x,-1,1,40], [y,-1,1,40]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="mi">100</span><span class="p">],</span> <span class="p">[</span><span class="mi">100</span><span class="p">])</span> <span class="c1"># [x,-1,1,100], [y,-1,1,100]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span><span class="o">-</span><span class="mi">13</span><span class="p">,</span><span class="mi">13</span><span class="p">,</span><span class="mi">100</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="o">-</span><span class="mi">13</span><span class="p">,</span><span class="mi">13</span><span class="p">])</span> <span class="c1"># [x,-13,13,100]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="n">x</span><span class="p">,</span><span class="o">-</span><span class="mi">13</span><span class="p">,</span><span class="mi">13</span><span class="p">])</span> <span class="c1"># [x,-13,13,100]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Plot</span><span class="p">(</span><span class="mi">1</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="p">[],</span> <span class="p">[</span><span class="n">x</span><span class="p">],</span> <span class="s1">&#39;mode=cylindrical&#39;</span><span class="p">)</span> <span class="c1"># [unbound_theta,0,2*Pi,40], [x,-1,1,20]</span>
</pre></div>
</div>
</section>
<section id="using-the-interactive-interface">
<h2>Using the Interactive Interface<a class="headerlink" href="#using-the-interactive-interface" title="Permalink to this headline">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Plot</span><span class="p">(</span><span class="n">visible</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">f</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">[1]: x**2, &#39;mode=cartesian&#39;</span>
<span class="go">[2]: 2*x, &#39;mode=cartesian&#39;</span>
<span class="go">[3]: 2, &#39;mode=cartesian&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">&lt;blank plot&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span>  <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s1">&#39;solid&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s1">&#39;wireframe&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">z</span><span class="p">,</span> <span class="p">(</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.9</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.4</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s1">&#39;both&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">style</span> <span class="o">=</span> <span class="s1">&#39;both&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="using-custom-color-functions">
<h2>Using Custom Color Functions<a class="headerlink" href="#using-custom-color-functions" title="Permalink to this headline">¶</a></h2>
<p>The following code plots a saddle and color it by the magnitude of its gradient:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">fz</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Fx</span><span class="p">,</span> <span class="n">Fy</span><span class="p">,</span> <span class="n">Fz</span> <span class="o">=</span> <span class="n">fz</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">fz</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="mi">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">fz</span><span class="p">,</span> <span class="s1">&#39;style=solid&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="n">Fx</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">Fy</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">Fz</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">**</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
</pre></div>
</div>
<p>The coloring algorithm works like this:</p>
<ol class="arabic simple">
<li><p>Evaluate the color function(s) across the curve or surface.</p></li>
<li><p>Find the minimum and maximum value of each component.</p></li>
<li><p>Scale each component to the color gradient.</p></li>
</ol>
<p>When not specified explicitly, the default color gradient is
f(0.0)=(0.4,0.4,0.4) -&gt; f(1.0)=(0.9,0.9,0.9). In our case, everything is
gray-scale because we have applied the default color gradient uniformly for
each color component. When defining a color scheme in this way, you might want
to supply a color gradient as well:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="n">Fx</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">Fy</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">Fz</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">**</span><span class="p">(</span><span class="mf">0.5</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.1</span><span class="p">,</span><span class="mf">0.1</span><span class="p">,</span><span class="mf">0.9</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.1</span><span class="p">,</span><span class="mf">0.1</span><span class="p">)</span>
</pre></div>
</div>
<p>Here’s a color gradient with four steps:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">gradient</span> <span class="o">=</span> <span class="p">[</span> <span class="mf">0.0</span><span class="p">,</span> <span class="p">(</span><span class="mf">0.1</span><span class="p">,</span><span class="mf">0.1</span><span class="p">,</span><span class="mf">0.9</span><span class="p">),</span> <span class="mf">0.3</span><span class="p">,</span> <span class="p">(</span><span class="mf">0.1</span><span class="p">,</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.1</span><span class="p">),</span>
<span class="gp">... </span>             <span class="mf">0.7</span><span class="p">,</span> <span class="p">(</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.1</span><span class="p">),</span> <span class="mf">1.0</span><span class="p">,</span> <span class="p">(</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span> <span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="n">Fx</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">Fy</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">Fz</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">**</span><span class="p">(</span><span class="mf">0.5</span><span class="p">),</span> <span class="n">gradient</span>
</pre></div>
</div>
<p>The other way to specify a color scheme is to give a separate function for each
component r, g, b. With this syntax, the default color scheme is defined:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">z</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.4</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.9</span><span class="p">,</span><span class="mf">0.9</span><span class="p">)</span>
</pre></div>
</div>
<p>This maps z-&gt;red, y-&gt;green, and x-&gt;blue. In some cases, you might prefer to use
the following alternative syntax:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">z</span><span class="p">,(</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.9</span><span class="p">),</span> <span class="n">y</span><span class="p">,(</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.9</span><span class="p">),</span> <span class="n">x</span><span class="p">,(</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.9</span><span class="p">)</span>
</pre></div>
</div>
<p>You can still use multi-step gradients with three-function color schemes.</p>
</section>
<section id="plotting-geometric-entities">
<span id="plot-geom"></span><h2>Plotting Geometric Entities<a class="headerlink" href="#plotting-geometric-entities" title="Permalink to this headline">¶</a></h2>
<p>The plotting module is capable of plotting some 2D geometric entities like
line, circle and ellipse. The following example plots a circle centred at
origin and of radius 2 units.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="o">*</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plot_implicit</span><span class="p">(</span><span class="n">Eq</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
</pre></div>
</div>
<p>Similarly, <code class="docutils literal notranslate"><span class="pre">plot_implicit()</span></code> may be used to plot any 2-D geometric structure from
its implicit equation.</p>
<p>Plotting polygons (Polygon, RegularPolygon, Triangle) are not supported
directly.</p>
</section>
<section id="plotting-with-ascii-art">
<h2>Plotting with ASCII art<a class="headerlink" href="#plotting-with-ascii-art" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.plotting.textplot.textplot">
<span class="sig-prename descclassname"><span class="pre">sympy.plotting.textplot.</span></span><span class="sig-name descname"><span class="pre">textplot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">W</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">55</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">H</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">21</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/plotting/textplot.py#L127-L164"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.plotting.textplot.textplot" title="Permalink to this definition">¶</a></dt>
<dd><p>Print a crude ASCII art plot of the SymPy expression ‘expr’ (which
should contain a single symbol, e.g. x or something else) over the
interval [a, b].</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">sin</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.plotting</span> <span class="kn">import</span> <span class="n">textplot</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">textplot</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">t</span><span class="p">)</span><span class="o">*</span><span class="n">t</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
<span class="go"> 14 |                                                  ...</span>
<span class="go">    |                                                     .</span>
<span class="go">    |                                                 .</span>
<span class="go">    |                                                      .</span>
<span class="go">    |                                                .</span>
<span class="go">    |                            ...</span>
<span class="go">    |                           /   .               .</span>
<span class="go">    |                          /</span>
<span class="go">    |                         /      .</span>
<span class="go">    |                        .        .            .</span>
<span class="go">1.5 |----.......--------------------------------------------</span>
<span class="go">    |....       \           .          .</span>
<span class="go">    |            \         /                      .</span>
<span class="go">    |             ..      /             .</span>
<span class="go">    |               \    /                       .</span>
<span class="go">    |                ....</span>
<span class="go">    |                                    .</span>
<span class="go">    |                                     .     .</span>
<span class="go">    |</span>
<span class="go">    |                                      .   .</span>
<span class="go">-11 |_______________________________________________________</span>
<span class="go">     0                          7.5                        15</span>
</pre></div>
</div>
</dd></dl>

</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Plotting</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#plot-class">Plot Class</a></li>
<li><a class="reference internal" href="#plotting-function-reference">Plotting Function Reference</a></li>
<li><a class="reference internal" href="#plotgrid-class">PlotGrid Class</a></li>
<li><a class="reference internal" href="#series-classes">Series Classes</a></li>
<li><a class="reference internal" href="#backends">Backends</a></li>
<li><a class="reference internal" href="#module-sympy.plotting.pygletplot">Pyglet Plotting</a></li>
<li><a class="reference internal" href="#plot-window-controls">Plot Window Controls</a></li>
<li><a class="reference internal" href="#coordinate-modes">Coordinate Modes</a></li>
<li><a class="reference internal" href="#specifying-intervals-for-variables">Specifying Intervals for Variables</a></li>
<li><a class="reference internal" href="#using-the-interactive-interface">Using the Interactive Interface</a></li>
<li><a class="reference internal" href="#using-custom-color-functions">Using Custom Color Functions</a></li>
<li><a class="reference internal" href="#plotting-geometric-entities">Plotting Geometric Entities</a></li>
<li><a class="reference internal" href="#plotting-with-ascii-art">Plotting with ASCII art</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="physics/continuum_mechanics/beam_problems.html"
                        title="previous chapter">Solving Beam Bending Problems using Singularity Functions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="polys/index.html"
                        title="next chapter">Polynomial Manipulation</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/modules/plotting.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="polys/index.html" title="Polynomial Manipulation"
             >next</a> |</li>
        <li class="right" >
          <a href="physics/continuum_mechanics/beam_problems.html" title="Solving Beam Bending Problems using Singularity Functions"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Plotting</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/plotting.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:25:34 GMT -->
</html>